package com.alibaba.config.config;


import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
@Data
public class ConfigBean {
    @Value("${user.name:defaultName}")
    String name;
    @Value("${user.age:10}")
    Integer age;
    @Value("${user.address:china}")
    String address;

/*    @Value("${user.address:china}") // @Value初始加载用于方法，会执行方法体;RefreshScope刷新配置时也会执行方法体（但配置为默认配置）。
    public void setAddress(String address){
        System.out.println("setAddress:"+address);
        this.address=address;
    }
    @Value("${user.address:china}")
    public void setAddress2(String address){
        System.out.println("setAddress2 setAddress2 setAddress2:"+address);
        this.address=address;
    }*/
}
